/*
Kakine
ActionScript Framework
Copyright © 2011, PUNY, LLC.

This file is part of KAKINE.

KAKINE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

KAKINE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KAKINE.  If not, see <http://www.gnu.org/licenses/>.
*/ 
package com.puny.utils
{
	/**
	 * mixed congruential method
	 * @author puny
	 * 
	 */
	public class SeededRandom extends Object
	{
		private static const _q:Number = 1861;
		private static const _p:Number = 9123456;
		private static const _d:Number = 10000000;
		private var _a:Number;
		public function SeededRandom(seed:Number)
		{
			_a = seed;
		}
		
		public function random():Number {
			_a = Math.floor((_a * _p + _q)/10) % _d;
			return _a / _d;
		}
		
		public function integer(n:Number):int {
			return int(random()*n);
		}
	}
}